import request from '@/utils/request'

export const getQueryCourses = data => {
  return request({
    method: 'POST',
    url: `/boss/course/getQueryCourses`,
    data,
  })
}

export const changeCourseState = params => {
  return request({
    method: 'GET',
    url: `/boss/course/changeState`,
    params,
  })
}

export const saveOrUpdateCourse = data => {
  return request({
    method: 'POST',
    url: `/boss/course/saveOrUpdateCourse`,
    data,
  })
}

/**
 * onUploadProgress 可以监听上传进度
 */
export const uploadCourseImage = (data, onUploadProgress) => {
  return request({
    method: 'POST',
    url: '/boss/course/upload',
    data,
    onUploadProgress,
  })
}

export const getCourseById = id => {
  return request({
    method: 'GET',
    url: `/boss/course/getCourseById`,
    params: {
      courseId: id,
    }
  })
}

export const getSectionAndLesson = courseId => {
  return request({
    method: 'GET',
    url: `/boss/course/section/getSectionAndLesson`,
    params: {
      courseId,
    }
  })
}

export const saveOrUpdateSection = data => {
  return request({
    method: 'POST',
    url: `/boss/course/section/saveOrUpdateSection`,
    data,
  })
}

export const saveOrUpdateLesson = data => {
  return request({
    method: 'POST',
    url: `/boss/course/lesson/saveOrUpdate`,
    data,
  })
}
